<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<div id="log"></div>
<script>
const isMac = navigator.platform.indexOf('Mac') === 0;
selection_test(
  [
    '<div contenteditable="true" id="root">',
        '<div>Before</div>',
        '<table style="border:3px solid #aaa;">',
            '<tr>',
                '<td>Foo</td>',
                '<td>baz</td>',
            '</tr>',
            '<tr>',
                '<td>bar</td>',
                '<td>buffalo</td>',
            '</tr>',
        '</table>',
        '<span id="start">^a|fter</span>',
    '</div>'
  ],
  selection => {
    selection.document.execCommand('delete');
    selection.document.execCommand('delete');
    selection.document.execCommand('delete');
  },
  isMac
    ? [
        '<div contenteditable="true" id="root">',
            '<div>Before</div>',
            '<table style="border:3px solid #aaa;">',
                '<tbody>',
                    '<tr>',
                        '<td>Foo</td>',
                        '<td>baz</td>',
                    '</tr>',
                    '<tr>',
                        '<td>bar</td>',
                        '<td>buffal|fter</td>',
                    '</tr>',
                '</tbody>',
            '</table>',
        '</div>',
      ]
    : [
        '<div contenteditable="true" id="root">',
            '<div>Before</div>',
            '<table style="border:3px solid #aaa;">',
                '<tbody>',
                    '<tr>',
                        '<td>Foo</td>',
                        '<td>baz</td>',
                    '</tr>',
                    '<tr>',
                        '<td>bar</td>',
                        '<td>buffalo</td>',
                    '</tr>',
                '</tbody>',
            '</table>|fter',
        '</div>',
      ],
    'This test checks that deleting into a table works properly.' +
    isMac
      ? 'When deleting three times with the cursor after the character "a" in the "after" text after the table, the "a" should be deleted, as should the "o" of "buffalo" in the last table cell.'
      : 'When deleting three times with the cursor after the character "a" in the "after" text after the table, the "a" should be deleted; the rest of the delete commands should do nothing.');
</script>
